require 'write_xlsx'
module NS
    module Output
        def excel_write(count,mode = 'row',info,path)
            puts count = count.to_i
            record = 0;
            # Create a new Excel workbook
            workbook = WriteXLSX.new(path)            
            # Add a worksheet
            worksheet = workbook.add_worksheet
            #  Add and define a format
            format = workbook.add_format
            format.set_bold
            format.set_color('black')
            format.set_align('center')
            # test whether write excel table?
            worksheet.write(0,12,"test",format)                        
            # Write a formatted and unformatted string, row and column notation.
            if mode == 'row' 
                while record < count do
                    puts info[record]
                    worksheet.write(0,record,info[record],format)
                    record = record + 1            
                end
            elsif mode == 'col'
                while record < count do
                    puts info[record]
                    worksheet.write(record,0,info[record],format)            
                    record = record + 1                                
                end
            end
            workbook.close
            # Write xlsx file to disk.
            # if die then workbook.close end
        end
    end
end